<?php

class Api{
    function get($req){
        $rows = pt\db\Mysql::init()->rows("select id,name from role order by id desc");
        return $rows;
    }
    function post($req){
        $dataSource = pt\db\Mysql::init()->rows("select *,id as `key` from role order by id desc");
        $total = pt\db\Mysql::init()->row("select count(id) as num from role ");
        $columns = array(
            array(
                "title"=>"ID",
                "key"=>"id",
                "dataIndex"=>"id",
            ),
            array(
                "title"=>"角色名",
                "key"=>"name",
                "dataIndex"=>"name",
            ),
            array(
                "title"=>"备注",
                "key"=>"notes",
                "dataIndex"=>"notes",
            ),
            array(
                "title"=>"操作",
                "key"=>"",
                "dataIndex"=>"",
            )
        );
        $res = array(
            "dataSource"=>$dataSource,
            "columns"=>$columns,
            "pagination"=>array(
                "total"=>$total['num'],
                "pageSize"=>5,
                "current"=>1,
            ),
        );
        return $res;
    }
}
